﻿@model Nop.Web.Models.Install.InstallModel
@{
    Layout = "~/Views/Shared/_Installation.cshtml";
}
@using (Html.BeginForm("Index", "Install", FormMethod.Post, new { id = "installationform" }))
{
    //Contributor : The orchard project. Thanks a lot!
    <script type="text/javascript">
        $(document).ready(function () {
            $('#installationform').submit(function () {
                if ($('form').valid()) {
                    $('input[type=submit]', this).attr('disabled', 'disabled');
                }
            });
        });

        $(document).ready(function () {
            $('input:radio[name=DataProvider]').click(toggleProvider);
            $('input:radio[name=SqlConnectionInfo]').click(toggleSqlConnectionInfo);
            $('input:radio[name=SqlAuthenticationType]').click(toggleSqlAuthenticationType);

            toggleProvider();
            toggleSqlConnectionInfo();
            toggleSqlAuthenticationType();
        });


        function toggleProvider() {
            var selectedProvider = $("input[name=DataProvider]:checked").attr('id');
            if (selectedProvider == 'provider_sqlce') {
                $('#sqlConnectionInfo').hide();
            }
            else if (selectedProvider == 'provider_sqlserver') {
                $('#sqlConnectionInfo').show();
            }
        }

        function toggleSqlConnectionInfo() {
            var selectedProvider = $("input[name=SqlConnectionInfo]:checked").attr('id');
            if (selectedProvider == 'sqlconnectioninfo_values') {
                $('#sqlDatabaseInfo').show();
                $('#sqlDatabaseConnectionString').hide();
            }
            else if (selectedProvider == 'sqlconnectioninfo_raw') {
                $('#sqlDatabaseInfo').hide();
                $('#sqlDatabaseConnectionString').show();
            }
        }

        function toggleSqlAuthenticationType() {
            var selectedProvider = $("input[name=SqlAuthenticationType]:checked").attr('id');
            if (selectedProvider == 'sqlauthenticationtype_sql') {
                $('#pnlSqlServerUsername').show();
                $('#pnlSqlServerPassword').show();
            }
            else if (selectedProvider == 'sqlauthenticationtype_windows') {
                $('#pnlSqlServerUsername').hide();
                $('#pnlSqlServerPassword').hide();
            }
        }


        (function () {
            function show() {
                window.setTimeout(function () {
                    document.getElementById("throbber").style.display = "block";
                }, 1000);
            }

            if (document.addEventListener) {
                document.addEventListener("submit", show, false);
            }
            else {
                document.forms[0].attachEvent("onsubmit", show);
            }
        })();
    </script>
    
    <table border="0" cellpadding="0" cellspacing="0" class="container-installer">
        <tr class="top">
            <td class="left">
                &nbsp;
            </td>
            <td class="center">
                &nbsp;
            </td>
            <td class="right">
                &nbsp;
            </td>
        </tr>
        <tr class="Middle">
            <td class="left">
                &nbsp;
            </td>
            <td class="center">
                <span class="header-text">nopCommerce installation</span><br />
                <div class="content">
                    <table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;">
                        <tbody>
                            <tr style="height: 100%;">
                                <td>
                                    <table class="wizard-step" border="0" cellpadding="0" cellspacing="10">
                                        @*<tr>
                                            <td colspan="2">
                                                <label class="title">
                                                    Thank you for choosing nopCommerce!</label>
                                            </td>
                                        </tr>*@
                                        <tr>
                                            <td colspan="2">
                                                <p>
                                                    @*<a href="http://www.nopCommerce.com/" target="_blank">nopCommerce</a> is the leading
                                                    ASP.NET online shop e-commerce solution. This wizard will guide you through the
                                                    process of configuring <strong>nopCommerce</strong>
                                                    <br />
                                                    <br />*@
                                                    To complete this wizard you must know some information regarding your database server
                                                    ("connection string"). Please contact your ISP if necessary. If you're installing
                                                    on a local machine or server you might need information from your System Admin.
                                                    <br />
                                                    <div style="color: Red;">
                                                @Html.ValidationSummary(false)
                                                </div>
                                                </p>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="left">
                                                <h3>Store information</h3>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td nowrap="nowrap" align="left">
                                                <label for="AdminEmail">
                                                    Admin user email:</label>
                                            </td>
                                            <td width="100%">
                                                @Html.TextBoxFor(x => x.AdminEmail, new { @class = "textbox" })
                                            </td>
                                        </tr>
                                        <tr>
                                            <td nowrap="nowrap" align="left">
                                                <label for="AdminPassword">
                                                    Admin user password:</label>
                                            </td>
                                            <td width="100%">
                                                @Html.PasswordFor(x => x.AdminPassword, new { @class = "textbox" })
                                            </td>
                                        </tr>
                                        <tr>
                                            <td nowrap="nowrap" align="left">
                                                <label for="ConfirmPassword">
                                                    Confirm the password:</label>
                                            </td>
                                            <td width="100%">
                                                @Html.PasswordFor(x => x.ConfirmPassword, new { @class = "textbox" })
                                            </td>
                                        </tr>
                                        <tr>
                                            <td nowrap="nowrap" align="left">
                                                <label for="InstallSampleData">
                                                    Create sample data:</label>
                                            </td>
                                            <td width="100%">
                                                @Html.CheckBoxFor(x => x.InstallSampleData)
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="left">
                                                <h3>Database information</h3>
                                                <hr />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="left">
                                                @Html.RadioButton("DataProvider", "sqlce", (Model.DataProvider == "sqlce"), new { id = "provider_sqlce" })
                                                <label for="provider_sqlce">
                                                    Use built-in data storage (SQL Server Compact).</label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" align="left">
                                                @Html.RadioButton("DataProvider", "sqlserver", (Model.DataProvider == "sqlserver"), new { id = "provider_sqlserver" })
                                                <label for="provider_sqlserver">
                                                    Use SQL Server (or SQL Express) database. <b>[Recommended]</b></label>
                                                <div id="sqlConnectionInfo">
                                                    <br />
                                                    <hr />
                                                    <br />
                                                    <div>
                                                        <table>
                                                            <tr>
                                                                <td nowrap="nowrap" align="left">
                                                                    <label for="SqlServerCreateDatabase">
                                                                        Create database if it doesn't exist:</label>
                                                                </td>
                                                                <td width="100%">
                                                                    @Html.CheckBoxFor(x => x.SqlServerCreateDatabase)
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                    <br />
                                                    @Html.RadioButton("SqlConnectionInfo", "sqlconnectioninfo_values", (Model.SqlConnectionInfo == "sqlconnectioninfo_values"), new { id = "sqlconnectioninfo_values" })
                                                    <label for="sqlconnectioninfo_values">
                                                        Enter SQL connection values</label>
                                                    @Html.RadioButton("SqlConnectionInfo", "sqlconnectioninfo_raw", (Model.SqlConnectionInfo == "sqlconnectioninfo_raw"), new { id = "sqlconnectioninfo_raw" })
                                                    <label for="sqlconnectioninfo_raw">
                                                        Enter raw connection string (advanced)</label>
                                                    <div id="sqlDatabaseInfo">
                                                        <table>
                                                            <tr>
                                                                <td nowrap="nowrap" align="left">
                                                                    <label for="SqlServerName">
                                                                        SQL Server name:</label>
                                                                </td>
                                                                <td width="100%">
                                                                    @Html.TextBoxFor(x => x.SqlServerName, new { @class = "textbox" })
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td nowrap="nowrap" align="left">
                                                                    <label for="SqlDatabaseName">
                                                                        Database name:</label>
                                                                </td>
                                                                <td width="100%">
                                                                    @Html.TextBoxFor(x => x.SqlDatabaseName, new { @class = "textbox" })
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <td align="left" colspan="2">
                                                                    @Html.RadioButton("SqlAuthenticationType", "sqlauthentication", (Model.SqlAuthenticationType == "sqlauthentication"), new { id = "sqlauthenticationtype_sql" })
                                                                    <label for="sqlauthenticationtype_sql">
                                                                        Use SQL Server account</label>
                                                                    @Html.RadioButton("SqlAuthenticationType", "windowsauthentication", (Model.SqlAuthenticationType == "windowsauthentication"), new { id = "sqlauthenticationtype_windows" })
                                                                    <label for="sqlauthenticationtype_windows">
                                                                        Use integrated Windows authentication</label>
                                                                </td>
                                                            </tr>
                                                            <tr id="pnlSqlServerUsername">
                                                                <td nowrap="nowrap" align="left">
                                                                    <label for="SqlServerUsername">
                                                                        SQL Username:</label>
                                                                </td>
                                                                <td width="100%">
                                                                    @Html.TextBoxFor(x => x.SqlServerUsername, new { @class = "textbox" })
                                                                </td>
                                                            </tr>
                                                            <tr id="pnlSqlServerPassword">
                                                                <td nowrap="nowrap" align="left">
                                                                    <label for="SqlServerPassword">
                                                                        SQL Password:</label>
                                                                </td>
                                                                <td width="100%">
                                                                    @Html.PasswordFor(x => x.SqlServerPassword, new { @class = "textbox" })
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </div>
                                                    <div id="sqlDatabaseConnectionString">
                                                        <span style="white-space: nowrap;">
                                                            <label for="DatabaseConnectionString">
                                                                Connection string:</label>
                                                            @Html.TextBoxFor(x => x.DatabaseConnectionString, new { @class = "textbox", style = "width:90%;" })
                                                        </span>
                                                        <br />
                                                        <span class="hint">Example:<br />
                                                            Data Source=sqlServerName;Initial Catalog=dbName;Persist Security Info=True;User
                                                            ID=userName;Password=password
                                                            <br />
                                                            Find more info <a href="http://www.connectionstrings.com/" target="_blank">here</a>
                                                        </span>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                &nbsp;
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                If you need information on how to use nopCommerce, visit <a href="http://www.nopCommerce.com/documentation.aspx" target="_blank">
                                                    the documentation section on nopCommerce.com</a>.
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                &nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <div style="float: right; padding: 0px 10px 0px 0px;">
                                        <input type="submit" value="Install" style="width: 100px;" />
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </td>
            <td class="right">
            </td>
        </tr>
        <tr class="Bottom">
            <td class="left">
                &nbsp;
            </td>
            <td class="center">
                &nbsp;
            </td>
            <td class="right">
                &nbsp;
            </td>
        </tr>
    </table>
    <div class="container-footer">
        <div style="text-align: left; padding: 0px 0px 0px 0px; color: #606060; float: left;">
            <a href="@Url.Action("RestartInstall", "Install")" title="Click to restart the installation process (clear all cached values)">
                Restart installation</a>
        </div>
        <div style="text-align: right; padding: 0px 0px 0px 0px; color: #606060; float: right;">
            All rights reserved
        </div>
    </div>
    <div id="throbber">
        <div class="curtain">
        </div>
        <div class="curtain-content">
            <div>
                <h1 id="setUpHeader">
                    Installing nopCommerce...</h1>
                <p>
                    <img src="@Url.Content("~/content/images/install-synchronizing.gif")" alt="" />
                </p>
            </div>
        </div>
    </div>
}